package com.hankol.newretail.adapter

import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.baselibrary.extension.checkValue
import com.baselibrary.extension.load
import com.baselibrary.extension.setMallPriceTTF
import com.baselibrary.utils.AmountUtil
import com.baselibrary.view.RoundCornerImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.newretail.R
import com.hankol.newretail.bean.MallOrderSkuDtoBean
import com.baselibrary.utils.SpecUtils
import com.hankol.newretail.bean.NoSupportSkuDtoBean
import com.hankol.newretail.bean.goods_details.MallProductGiftCommodityVo

/*查看原因 列表 */
class SeeReasonGoodsListingAdapter : BaseQuickAdapter<NoSupportSkuDtoBean, BaseViewHolder>(R.layout.item_see_reason_goods_listing) {

    override fun convert(helper: BaseViewHolder, item: NoSupportSkuDtoBean) {
        helper.apply {
            item.let {
                getView<RoundCornerImageView>(R.id.img_cover).load(mContext, it.skuCover.checkValue())
                setText(R.id.tv_name, it.spuName.checkValue())
                setText(R.id.tv_num, "x${it.num}")
                setText(R.id.tv_price, AmountUtil.changeF2YKeepTwo("${it.price}"))
                setText(R.id.tv_spec, SpecUtils.getNormsStr(it.specList))
                helper.getView<TextView>(R.id.tv_price).setMallPriceTTF(mContext)
                setText(R.id.tv_buypolicy_text, it.buyPolicyText.checkValue())
                if (!item.mallProductGiftCommodityVos.isNullOrEmpty()) {
                    setGone(R.id.ll_gift, true)
                    val goodsGiftConfirmOrderAdapter = GoodsGiftConfirmOrderAdapter()
                    helper.getView<RecyclerView>(R.id.rv_gift_list).adapter = goodsGiftConfirmOrderAdapter
                    goodsGiftConfirmOrderAdapter.setNewData(it.mallProductGiftCommodityVos)
                } else {
                    setGone(R.id.ll_gift, false)
                }
            }
        }
    }
}